// 绘制区域围栏
function getBoundary(map) {
  const bdary = new BMap.Boundary()
  return new Promise((resolve, reject) => {
    bdary.get('北京市北京市顺义区', (rs) => {
      console.log(1)
      const count = rs.boundaries.length
      if (count === 0) {
        return
      }

      map.clearOverlays()
      var pointArray = []
      for (var i = 0; i < count; i++) {
        var ply = new BMap.Polygon(rs.boundaries[i], {
          strokeWeight: 2,
          strokeColor: '#ff0000',
          fillOpacity: 0.01,
        }) //建立多边形覆盖物
        map.addOverlay(ply) //添加覆盖物
        pointArray = pointArray.concat(ply.getPath())
      }
      map.setViewport(pointArray)
      console.log(3)
      resolve(true)
    })
  })

}

export { getBoundary }
